using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.Collections.Generic;
using System.ComponentModel;
namespace ePlanSysOman
{
    public partial class frmSel
    {

        private int FRMO = 0;
        private string PlanNumber = "";
        private int thru = 0;
        private string typever = "";
        private void  // ERROR: Handles clauses are not supported in C#
    SimpleButton1_Click(System.Object sender, System.EventArgs e)
        {
            this.Close();
            //Dim ans As DialogResult
            //ans = XtraMessageBox.Show("Add more ECN ?", "Creating", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            //If ans = Windows.Forms.DialogResult.Yes Then
            //    ' GridControl1_DoubleClick(sender)


            //End If
            //If ans = Windows.Forms.DialogResult.No Then

            //    'Dim cd As New clsData




            //    'Select Case ComboBoxEdit1.SelectedIndex
            //    '    Case "0"
            //    '        Dim frm As New frmElectrical
            //    '        PLANTYPE = "ELECTRICAL"
            //    '        frm.MdiParent = frmMain
            //    '        frm.Show()



            //    '    Case "1"
            //    '        ''     Dim frm As New frmApg
            //    '        'PLANTYPE = "APG"
            //    '        'frm.MdiParent = frmMain
            //    '        'frm.Show()
            //    '    Case "3"
            //    '        Dim frm As New frmSheetMetal
            //    '        PLANTYPE = "SHEETMETAL"
            //    '        frm.MdiParent = frmMain
            //    '        frm.Show()
            //    '        'OPS()
            //    '        'INDUCTION()
            //    '        'HARDWARE()
            //    '        'REMOVAL()
            //    '        'INSTALLATION()

            //    ' End Select

            // End If


        }

        private void ComboBoxEdit1_SelectedIndexChanged(System.Object sender, System.EventArgs e)
        {


        }
        private void  // ERROR: Handles clauses are not supported in C#
    frmSel_Load(object sender, System.EventArgs e)
        {
            this.PlanNumber = Module1.newModule.plnumber;
            clsData data = new clsData();
            DataSet aset = new DataSet();
            if (Module1.newModule.stpParts)
            {
                aset = data.getData("Select * from tblEcn");
                this.GridControl1.DataSource = aset.Tables[0];
                this.SimpleButton1.Text = "NEXT";
                Module1.newModule.stpParts = false;
            }
            else
            {
                if (!Module1.newModule.BAckhrn)
                {
                    if (!Module1.newModule.OpsEcn)
                    {
                        //frmPLANNUMBER.newfrmPLANNUMBER1.Close(); // BJR
                        this.ComboBoxEdit1.SelectedItem = Module1.newModule.TEAM;
                        if (Module1.newModule.startAgain)
                        {
                            data.ExecuteSQL(string.Concat(new string[] {
                "UPDATE tblEcn set  comment ='",
                Module1.newModule.ecnComment,
                " ,Started Pl/c ",
                Module1.newModule.STRPLANO,
                " 'where ECN = '",
                Module1.newModule.stath,
                "'  AND DASH ='",
                Module1.newModule.DRWREV,
                "' AND TYPEVER ='",
                Module1.newModule.tv,
                "' AND FR0M ='",
                Module1.newModule.strFrmo,
                "' AND THRU='",
                Module1.newModule.strTHRU,
                "'"
              }));
                        }
                        else
                        {
                            data.ExecuteSQL(string.Concat(new string[] {
                "UPDATE tblEcn set  comment =' Started Pl/c ",
                Module1.newModule.STRPLANO,
                " 'where DRAWING ='",
                Module1.newModule.DrwNo,
                "' and  ECN = '",
                Module1.newModule.stath,
                "'  AND DASH ='",
                Module1.newModule.DRWREV,
                "' AND TYPEVER ='",
                Module1.newModule.tv,
                "' AND FR0M ='",
                Module1.newModule.strFrmo,
                "' AND THRU ='",
                Module1.newModule.strTHRU,
                "'"
              }));
                        }
                        if (!Module1.newModule.Template)
                        {
                            data.ExecuteSQL(string.Concat(new string[] {
                "INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ('",
                Module1.newModule.plnumber,
                "','",
                Module1.newModule.tv,
                "','",
                Conversions.ToString(Module1.newModule.fr),
                "','",
                Conversions.ToString(Module1.newModule.trhu),
                "')"
              }));
                            data.ExecuteSQL(string.Concat(new string[] {
                "INSERT INTO TBLPLANO(PlannoId,AREANO,DESCRIPTION,revchng,typeVer,Program,plFrom,plThru) VALUES ('",
                Module1.newModule.plnumber,
                "','",
                Conversions.ToString(Module1.newModule.AreaNo),
                "',",
                Conversions.ToString(Module1.newModule.strPlannumber),
                ",'",
                Module1.newModule.EFFECTIVITIES,
                "','','",
                frmMain.start.cmbProgram.Text,
                "','','')"
              }));
                        }
                    }
                    else
                    {
                        Module1.newModule.OpsEcn = false;
                    }
                }
                aset = data.getData("Select * FROM tblEcn");
                this.GridControl1.DataSource = aset.Tables[0];
            }
        }

        private void  // ERROR: Handles clauses are not supported in C#
    GridControl1_Click(System.Object sender, System.EventArgs e)
        {

        }

        private void  // ERROR: Handles clauses are not supported in C#
    GridControl1_DoubleClick(object sender, System.EventArgs e)
        {
            int focusedRowHandle = this.GridView1.FocusedRowHandle;
            string str2 = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "ECN"));
            string source = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "DRAWING"));
            Module1.newModule.tv = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "TYPEVER"));
            Module1.newModule.strFrmo = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "FR0M"));
            Module1.newModule.strTHRU = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "THRU"));
            Module1.newModule.fr = Conversions.ToInteger(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "FR0M"));
            Module1.newModule.trhu = Conversions.ToInteger(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "THRU"));
            Module1.newModule.ECP = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "RCN"));
            string str3 = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "DRAWINGTITLE"));
            string str4 = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "DASH"));
            Module1.newModule.ProgramId = Conversions.ToString(this.GridView1.GetRowCellValue(this.GridView1.GetSelectedRows()[0], "COMMENT"));
            clsData data2 = new clsData();
            DialogResult result = DevExpress.XtraEditors.XtraMessageBox.Show(("You are going to add '" + str2 + "' ecn to this planning Card are you sure ?"), "Adding Ecns", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if ((((Module1.newModule.ProgramId == "") | LikeOperator.LikeString(Module1.newModule.ProgramId, "*NEW*", CompareMethod.Binary)) | LikeOperator.LikeString(Module1.newModule.ProgramId, "*lanned*", CompareMethod.Binary)))
            {
                Module1.newModule.ecnComment = "";
                Module1.newModule.ecnComment = (Module1.newModule.ecnComment + "Started Pl/c " + Module1.newModule.STRPLANO);
                Module1.newModule.stath = str2;
            }
            else if (Module1.newModule.ProgramId.Contains(Module1.newModule.STRPLANO))
            {
                Module1.newModule.ecnComment = Module1.newModule.ProgramId;
            }
            else
            {
                Module1.newModule.ecnComment = Module1.newModule.ProgramId;
                Module1.newModule.ecnComment = (Module1.newModule.ecnComment + ",");
                Module1.newModule.startinG = false;
                Module1.newModule.ecnComment = (Module1.newModule.ecnComment + " Started Pl/c " + Module1.newModule.STRPLANO);
            }
            DataSet aset = new DataSet();
            clsData data = new clsData();
            if ((result == DialogResult.Yes))
            {
                data2.ExecuteSQL(string.Concat(new string[] {
          "INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '",
          this.PlanNumber,
          "','",
          source,
          "-",
          str2,
          "','ECN','",
          str4,
          "','",
          Module1.newModule.tv,
          "',",
          Conversions.ToString(Module1.newModule.fr),
          ",",
          Conversions.ToString(Module1.newModule.trhu),
          ",'",
          str2,
          "','Started Pl/c ",
          Module1.newModule.STRPLANO,
          "')"
        }));
                data2.ExecuteSQL(string.Concat(new string[] {
          "UPDATE tblEcn set comment ='",
          Module1.newModule.ecnComment,
          "' where ECN = '",
          str2,
          "' and DRAWING ='",
          source,
          "' and DASH ='",
          str4,
          "'AND TYPEVER ='",
          Module1.newModule.tv,
          "' AND FR0M ='",
          Module1.newModule.strFrmo,
          "' AND THRU='",
          Module1.newModule.strTHRU,
          "'"
        }));
                data2.ExecuteSQL(string.Concat(new string[] {
          "INSERT INTO tblEffectivities(efPlid,efTypeVer,efFrom,efThru) VALUES ('",
          this.PlanNumber,
          "','",
          Module1.newModule.tv,
          "','",
          Conversions.ToString(Module1.newModule.fr),
          "','",
          Conversions.ToString(Module1.newModule.trhu),
          "')"
        }));
                if (!LikeOperator.LikeString(source, "*H16DW*", CompareMethod.Binary))
                {
                    data2.ExecuteSQL(string.Concat(new string[] {
            "INSERT INTO TBLDRAWINGS (DWGPLID,dwgpartnumber,DWGDESCRIPTION,DWGNOTES,dwgTypeVer,dwgFrom,dwgThru,dwgEcn,dwgStatus) VALUES ( '",
            Module1.newModule.plnumber,
            "','",
            source,
            "','B/P','",
            str4,
            "','",
            Module1.newModule.tv,
            "',",
            Conversions.ToString(Module1.newModule.fr),
            ",",
            Conversions.ToString(Module1.newModule.trhu),
            ",'",
            str2,
            "','Started Pl/c ",
            Module1.newModule.STRPLANO,
            "')"
          }));
                }
                aset = data.getData("Select * from tblEcn");
                this.GridControl1.DataSource = aset.Tables[0];
                this.GridControl1.RefreshDataSource();
                this.GridView1.FocusedRowHandle = focusedRowHandle;
            }
        }

        public frmSel()
        {
            InitializeComponent();
        }
    }
}

